#!/bin/sh -f

# patch Xcode to add icons for Pascal source files
cd "$3/Developer/Applications/Xcode.app/Contents"
if [ -f "Info.plist.rej" ] ; then
	rm -f "Info.plist.rej"
	rm -f "Info.plist.orig"
fi
if [ ! -f "Info.plist.orig" ] ; then
	patch -p0 -N -s -i "Info.plist.diff"
fi

# rename Free Pascal project template directories
cd "$3/Library/Application Support/Apple/Developer Tools/Project Templates"
if [ ! -d "FreePascal" ] ; then
	mv -n "Pascal" "FreePascal"
fi
if [ ! -d "FreePascal Carbon Application 2.1" ] ; then
	mv -n "Pascal Carbon Application 2.1" "FreePascal Carbon Application 2.1"
fi

# add a symbolic link to the GNU Pascal examples in the Xcode Examples folder
ln -sfh "$3/Developer/Pascal/GPC Xcode Kit 1.1/Examples" "$3/Developer/Examples/GNU Pascal Examples"

exit 0
